package com.wanxi.util;


import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;

public class Base64Code  {

    //加密
    public static  String enCode(String pass){

        try {
            //md5编码
            MessageDigest instance = MessageDigest.getInstance("MD5");
            Base64.Encoder encoder = Base64.getEncoder();
            //开始加密
            String s = encoder.encodeToString(instance.digest(pass.getBytes()));
            return s;

        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }

        return pass;

    }

    //解密
    /*public static String deCode(String pass){
        Base64.Decoder decoder = Base64.getDecoder();

        byte[] decode = decoder.decode(pass.getBytes());

        return Arrays.toString(decode);
    }*/


}
